@import '../../styles/colors.scss';
@import '../../styles/spacing.scss';
@import '../../styles/variables.scss';
@import '../../styles/typography.scss';

$baseClass: 'vant-field';

.#{$baseClass} {
  @include field-label;
  width: 100%;
  background-color: $default;
  padding: 10px $space-lg;
  display: flex;
  overflow: hidden;
  position: relative;

  .#{$baseClass}__label {
    display: flex;
    align-items: center;
    width: 90px;

    .vant-icon__container {
      margin-right: 5px;
    }
  }

  .#{$baseClass}__input {
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;
    color: $grey;
    word-wrap: break-word;
    vertical-align: middle;
    position: relative;

    .#{$baseClass}__field {
      display: flex;
      width: inherit;
    }

    .vant-icon__container {
      padding: 0 5px;
    }

    button {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
    }
  }

  .#{$baseClass}__error {
    color: $danger;
    font-size: 12px;
    text-align: left;
  }

  .#{$baseClass}__word-limit {
    margin-top: $space-sm;
    font-size: 12px;
    color: $word-limit;
    line-height: 16px;
    text-align: right;
  }

  input {
    @include field-label;
    width: inherit;
    outline: none;
    display: block;
    text-align: left;
    line-height: inherit;
    border: 0;
    resize: none;
    padding: 0;

    &::placeholder {
      color: $placeholder;
    }
  }

  &__disabled {
    input {
      color: $grey;
    }
  }

  &__error,
  &__showWordLimit {
    .full {
      color: $danger;
    }

    .#{$baseClass}__label {
      align-items: flex-start;
    }
  }

  &__input-center {
    input {
      text-align: center;
    }
  }
  &__input-right {
    input {
      text-align: right;
    }
  }

  &__label-center {
    .#{$baseClass}__label {
      justify-content: center;
    }
  }
  &__label-right {
    .#{$baseClass}__label {
      justify-content: flex-end;
    }
  }

  &__error-right {
    .#{$baseClass}__error {
      text-align: right;
    }
  }
  &__error-center {
    .#{$baseClass}__error {
      text-align: center;
    }
  }

  &__required {
    .#{$baseClass}__label {
      label {
        &::before {
          position: absolute;
          left: $space-md;
          color: $danger;
          font-size: 14px;
          content: '*';
        }
      }
    }
  }

  &__border {
    &:not(:last-child)::after {
      position: absolute;
      box-sizing: border-box;
      content: ' ';
      pointer-events: none;
      right: 0;
      bottom: 0;
      left: $space-lg;
      border-bottom: 1px solid $grey-text;
      transform: scaleY(0.5);
    }
  }
}
